package io.gitee.xyuesheng.day03;

import java.awt.*;

public class HomeworkRectangle {
    //两个名为width 和 height的double类型成员变量，分别表示矩形的宽和高。
    //width 和height 的默认值都为 1
    private double width = 1.0;
    private double height = 1.0;

    //添加一个无参的构造器
    public HomeworkRectangle() {
        System.out.println("请输入宽width:");
        System.out.println("请输入长height:");
    }

    //添加—个创建能传入width 和 height 为参数的矩形的构造器
    public HomeworkRectangle(double width, double height) {
        this.width = width;
        this.height = height;
    }

    //添加一个名为 getArea（）的方法返回这个矩形的面积
    public double getArea(double width, double height) {
        double area = width * height;
        return area;
    }

    //添加一个名为 getPerimeter() 的方法返回周长
    public double getPerimeter(double width, double height) {
        double perimeter = 2 * (width + height);
        return perimeter;
    }


    //添加width和height的getter和setter方法
    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }


    //添加一个toString方法
    public String toString() {
        return "width:" + width + ","
                + "height:" + height + ","
                + "area" + getArea(width, height) + ","
                + "perimeter" + getPerimeter(width, height);
    }


}
